package com.flyoil.petromp.mvp_p.SearchCertainPresenter;

import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchBaseModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchCourseFinanceModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchGoodsApproveModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchGoodsDateExamineModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchGoodsDemandModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchGoodsExamineModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchGoodsOrderModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchCoursePlanModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchServiceApproveModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchServiceDemandModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchServiceExamineModel;
import com.flyoil.petromp.mvp_m.SearchCertainModel.SearchServiceOrderModel;
import com.flyoil.petromp.mvp_p.Listener.BasePresenter;
import com.flyoil.petromp.mvp_v.MessageUIView.SearchInputCertainMessageUIView;
import com.flyoil.petromp.utils.OrderUtl.OrderListUtil;

import java.util.List;
import java.util.Map;

/**
 * Created by songzhiyin on 2017/11/1.
 * 流程列表搜索输入数据界面的逻辑处理层
 */

public class SearchInputCertainPresenter implements BasePresenter {
    private SearchInputCertainMessageUIView view;
    private SearchBaseModel model;
    private String type = "";

    public SearchInputCertainPresenter(SearchInputCertainMessageUIView baseUIView, String type) {
        this.view = baseUIView;
        this.type = type;
        model = new SearchCoursePlanModel();
        initModel();
    }

    @Override
    public void onsucced(List data) {
        view.updataToUI(data);
        if (type.equals(OrderListUtil.FINANCE)) {//付款申请，不显示日期选择器
            view.showDateView(false);
        } else {
            view.showDateView(true);
        }
    }

    @Override
    public void initNetworkData(Map<String, Object> map) {

    }
    public void loadUiData(){
        model.loadUiData(this);
    }

    /**
     * 初始化model
     */
    private void initModel() {
        switch (type) {
            case OrderListUtil.PLAN:
                model = new SearchCoursePlanModel();
                break;
            case OrderListUtil.GOODS_DEMAND:
                model = new SearchGoodsDemandModel();
                break;
            case OrderListUtil.GOODS_APPROVE:
                model = new SearchGoodsApproveModel();
                break;
            case OrderListUtil.GOODS_ORDER:
                model = new SearchGoodsOrderModel();
                break;
            case OrderListUtil.GOODS_EXAMINE:
                model = new SearchGoodsExamineModel();
                break;
            case OrderListUtil.GOODS_DATE_EXAMINE:
                model = new SearchGoodsDateExamineModel();
                break;
            case OrderListUtil.SERVICE_DEMAND:
                model = new SearchServiceDemandModel();
                break;
            case OrderListUtil.SERVICE_APPROVE:
                model = new SearchServiceApproveModel();
                break;
            case OrderListUtil.SERVICE_ORDER:
                model = new SearchServiceOrderModel();
                break;
            case OrderListUtil.SERVICE_EXAMINE:
                model = new SearchServiceExamineModel();
                break;
            case OrderListUtil.FINANCE:
                model = new SearchCourseFinanceModel();
                break;

        }
    }
}
